#include<iostream>
using namespace std;
int L[201][201] = { 0 };
int LCS(string& s1, string& s2)
{
	int i = 0;
	int j = 1;
	for (i; i <= s1.size(); i++)
	{
		int j = 1;
		for (j; j <= s2.size(); j++)
		{
			if (s1[i - 1] == s2[j - 1])
				L[i][j] = L[i - 1][j - 1] +  1;
			else
				L[i][j] = max(L[i - 1][j], L[i][j - 1]);
		}
	}
	return L[s1.size()][s2.size()];
}
int main()
{
	string s1, s2;
	cin >> s1 >> s2;
	cout << LCS(s1, s2);
}
